# 方法1
def num(x):
    a = []
    for i in range(1, x):
        if x % i == 0:
            a.append(i)
    if sum(a) == x:
        return True

w = []
for e in range(1, 1001):
    if num(e):
        w.append(e)
print(f"0到1000中的完数有{w}")


# 方法2
def num(x):
    a = []
    for i in range(1, x):
        if x % i == 0:
            a.append(i)
    if sum(a) == x:
        print(f"0到1000中的完数有{x}")

for e in range(1, 1001):
    num(e)

# 方法3
for i in range(1, 1000):
    n = 0
    for e in range(1, i):
        if i % e == 0:
            n += e
    if n == i:
        print(f"{n}是完数")



